package cn.edu.scau.cmi.liquan.exercise9.Example9_29;

import java.util.Calendar;

public class OutputDayOfMonth {
     public int[] getDay(int year,int month) {
    	 Calendar calendar=Calendar.getInstance();
    	 calendar.set(year, month-1,1);
    	 int days[]=new int[42];
    	 int day;
    	 switch(month) {
    	 case 1:
    	 case 3:
    	 case 5:
    	 case 7:
    	 case 8:
    	 case 10:
    	 case 12:day=31;break;
    	 case 4:
    	 case 6:
    	 case 9:
    	 case 11:day=30;break;
    	 default:
    		 if((year%4==0&&year%100!=0)||(year%400==0)) {
    			 day=29;
    		 }
    		 else {
    			 day=28;
    		 }
    	 }
    	int firstWeek;
    	firstWeek=calendar.get(Calendar.DAY_OF_WEEK)-1;
    	for(int i=0;i<firstWeek;i++) {
    		days[i]=0;
    	}
    	for(int i=firstWeek,j=1;i<firstWeek+day;i++) {
    		days[i]=j;
    		j++;
    	}
    	for(int i=firstWeek+day;i<days.length;i++) {
    		days[i]=0;
    	}
    	return days;
     }
      
}
